package br.com.mmca.admrespaco.view;

import javax.inject.Inject;

import br.gov.frameworkdemoiselle.annotation.PreviousView;
import br.gov.frameworkdemoiselle.stereotype.ViewController;
import br.gov.frameworkdemoiselle.template.AbstractEditPageBean;
import br.gov.frameworkdemoiselle.transaction.Transactional;

import br.com.mmca.admrespaco.business.ReservaBC;
import br.com.mmca.admrespaco.domain.Reserva;

@ViewController
@PreviousView("/reserva_list.xhtml")
public class ReservaEditMB extends AbstractEditPageBean<Reserva, Long> {

	private static final long serialVersionUID = 1L;

	@Inject
	private ReservaBC reservaBC;

	@Override
	@Transactional
	public String delete() {
		this.reservaBC.delete(getId());
		return getPreviousView();
	}

	@Override
	@Transactional
	public String insert() {
		this.reservaBC.insert(getBean());
		return getPreviousView();
	}

	@Override
	@Transactional
	public String update() {
		this.reservaBC.update(getBean());
		return getPreviousView();
	}

	@Override
	protected void handleLoad() {
		setBean(this.reservaBC.load(getId()));
	}

}
